import router from "@/router"
export default{
    namespaced: true,
    state:{
        sidebarOpened: false,
        tagViewList: [
            {
                path:"/home",
                meta:{
                  title:"首页",
                }
              }
        ],
    },
    mutations:{
        toggleSwich(state){
            state.sidebarOpened = !state.sidebarOpened 
        },

        //增加tag
        addTagItem(state, tagRoute){
            let isfind = state.tagViewList.find(item =>item.path ===tagRoute.path);
            !isfind && state.tagViewList.push(tagRoute)
        },
        removeTagsItem(state,{index, isroute}){
            state.tagViewList.splice(index, 1);
            // console.log(state.tagViewList[state.tagViewList.length-1]);
            if(isroute) router.push(state.tagViewList[state.tagViewList.length-1].path);
            
            
        }
    }

}